from pydantic import BaseModel
from typing import List, Optional

class ItemModel(BaseModel):
    """物料项模型"""
    item: str
    qty: int
    signed_qty: int = 0

class BrandModelItem(BaseModel):
    """品牌型号项模型"""
    brand: str
    model: str
    specification: str
    origin: Optional[str] = ""
    quantity: int
    item: Optional[str] = None

class SignDataItem(BaseModel):
    """单个签单数据项"""
    picking_id: str
    contract_no: str
    item: str
    brand: str
    model: str
    origin: str
    qty: int

class SignDataRequest(BaseModel):
    """签单数据请求"""
    contract_no: str
    picking_id: str
    work_order: Optional[str] = ""
    brand_models: List[BrandModelItem] = []
    skip_validation: Optional[bool] = False  # 是否跳过验证直接提交，用于处理不需要签单的识别码

class BillDataResponse(BaseModel):
    """签单数据响应"""
    contract_no: str
    self_made_items: List[ItemModel]
    purchased_items: List[ItemModel]
    self_made_total_qty: int
    self_made_remaining_qty: int
    purchased_total_qty: int
    purchased_remaining_qty: int

class SubmitResponse(BaseModel):
    """提交响应"""
    success: bool
    message: str 